package jinzhi;


//K进制下 求各个位数的和  TODO:  记住这个算法
public class basic1837 {
    public int sumBase(int n, int k) {
     int count=0;

     while (n!=0){
         int  temp=n%k;
         count+=temp;
         n/=k;
     }
//        while (num!=0){
//            if (num<0){
//                flag=1;
//                num=-num;
//            }
//            stringBuffer.insert(0,num%7);
//            num=num/7;
//        }

//        count=count+ n%k;

     return  count;
    }

    public static void main(String[] args) {
        basic1837 basic1837 = new basic1837();
        System.out.println(basic1837.sumBase(124, 6));

    }

}
